//
//  RecordTableViewCell.m
//  ZZLC
//
//  Created by 杨春至 on 2017/12/18.
//  Copyright © 2017年 ZhongZeng. All rights reserved.
//

#import "RecordTableViewCell.h"

@implementation RecModel : NSObject

@end

@interface RecordTableViewCell ()
@property (nonatomic,strong) UILabel *titleLb;
@property (nonatomic,strong) UILabel *detaiLb;
@property (nonatomic,strong) UILabel *desLb;
@end
@implementation RecordTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier]) {
        [self configUI];

    }
    return self;
}
- (void)setModel:(RecModel *)model{
    _model = model;

    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy.MM.dd"];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[_model.payTime integerValue]/1000];
    NSString *dateStr = [formatter stringFromDate:date];
    self.titleLb.text = _model.username;
    self.detaiLb.text = dateStr;
    self.desLb.text =  _model.copies;
}
- (void)configUI{   
    [self.contentView addSubview:self.titleLb];
    [self.contentView addSubview:self.detaiLb];
    [self.contentView addSubview:self.desLb];
}
- (void)layoutSubviews{
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@5);
        make.left.equalTo(self).offset(15);
        make.height.equalTo(@16);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
    [_detaiLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-5);
        make.left.equalTo(self).offset(15);
        make.height.equalTo(@16);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
    [_desLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-15);
        make.height.equalTo(@16);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
    
}
- (UILabel *)desLb{
    if (!_desLb) {
        _desLb = [[UILabel alloc]init];
        _desLb.font = [UIFont systemFontOfSize:14];
        _desLb.textAlignment = NSTextAlignmentRight;
        _desLb.textColor = RGBCOLOR(130, 130, 130);
        
    }
    return _desLb;
}
- (UILabel *)titleLb{
    if (!_titleLb) {
        _titleLb = [[UILabel alloc]init];
        _titleLb.font = [UIFont systemFontOfSize:14];
        _titleLb.textColor = RGBCOLOR(130, 130, 130);
        
    }
    return _titleLb;
}
- (UILabel *)detaiLb{
    if (!_detaiLb) {
        _detaiLb = [[UILabel alloc]init];
        _detaiLb.font = [UIFont systemFontOfSize:14];
        _detaiLb.textColor = RGBCOLOR(130, 130, 130);
        
    }
    return _detaiLb;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
